<?php
namespace app\admin\controller;
use think\Db;
use think\Request;
use think\Controller;

class Common extends Controller
{
public static function doFileData($file,$size,$format,$folder)
{
    $info = $file->validate(['size'=>$size,'ext'=>$format])->move(ROOT_PATH.'public'.DS.'uploads//'.$folder);
    if ($info) {
        $file_info['image_src'] = $info->getSaveName();
        $file_info['format'] = $info->getExtension();
        $file_info['size'] = $info->getSize();
        return $file_info;
    } else{
        return $file->getError();
    }
}

public function setKeyWord($string)
{
    if (is_array($string)) {
        $string = implode(',',$string);
    }
    $list = Db::name('sensitive')->field(['word','replace'])->select();
    foreach ($list as $item) {
        $string = str_replace($item['word'],$item['replace'],$string);
    }
    return $string;
}

}